import React, { Component } from 'react';

import CommentList from './comment/CommentList';
import CommentForm from './comment/CommentForm';

import './semantic/dist/semantic.min.css';
import './App.css';

import $ from 'jquery';



class App extends Component {

  constructor(props) {
    super(props);
    this.state = {data: []};
    $.ajax({
      url: this.props.url,
      datType: 'json',
      cahce: false,
      success: comments => {
        this.setState({data: comments});
      },
      error: (xhr,status,error) => {
        console.log(error);
      }
    })
  }

  render() {
    return (
      <div className="main ui comments">
        <h1>评论</h1>
        <div className="ui divider"></div>
        <CommentList data={this.state.data} />
        <CommentForm />
      </div>
    );
  }
}

export default App;
